﻿using Abp.AutoMapper;
using Abp.Logging;
using AVIS.OutBound.WizardAgent;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AVIS.OutBound.CarGroups
{
    /// <summary>
    /// 车辆功能特征（比如：自动挡、4座等）
    /// </summary>
    [AutoMapFrom(typeof(CarFeatureDto))]
    [Serializable]
    public class CarFeature
    {
        /*
         * Wizard接口返回的数据如下：
         * <Reference Type="Features" ID="Smoke Free|4 Door|Seats 7|AM/FM Radio|CD Player|Air Bags|Air Conditioning|Power Steering|Power Locks|Power Windows|Anti-Lock Brakes|Cruise Control|Tilt Steering Wheel|Automatic|Holds 1 large, 1 small Suitcases|14-19 mpg|image=2016-chevrolet-tahoe-lt-suv-black.png|thumb=2016-chevrolet-tahoe-lt-suv-black.png|cargroup=Z|category=Full Size SUV"/>
         * Smoke Free：      无烟
         * 2 or 4 Doors：    2门或4门
         * Seats 5：         5座
         * AM/FM Radio：     调幅/调频收音机
         * Air Bags：        空气袋
         * Air Conditioning：空调
         * Power Steering：  动力转向
         * Power Brakes：    动力制动
         * Power Windows：   电动车窗
         * Automatic：       自动挡
         * Holds 1 large, 2 small Suitcases：可容纳一个大的，两个小的行李箱
         * 28-48 mpg:
         * image=2016-ford-focus-se-sedan-side-view-race-red.png:
         * thumb=2016-ford-focus-se-sedan-side-view-race-red.png:
         * cargroup=B:
         * category=Compact：类型=紧凑
         */

        /// <summary>
        /// 车辆有几门（如：2门、4门等）
        /// </summary>
        public string Doors { get; set; }

        /// <summary>
        /// 车辆有几座（如：2座、4座等）
        /// </summary>
        public string Seats { get; set; }

        /// <summary>
        /// 是否为自动挡
        /// </summary>
        public bool? IsAutomatic { get; set; }

        /// <summary>
        /// 是否有空调
        /// </summary>
        public bool? HasAirConditioning { get; set; }

        /// <summary>
        /// 可容纳多少件行李箱（如：Holds 2 small Suitcases）
        /// </summary>
        public string Suitcases { get; set; }

        /// <summary>
        /// 车辆类型：如紧凑、宽敞等
        /// </summary>
        public string Category { get; set; }

        /// <summary>
        /// 功能特征的描述信息
        /// </summary>
        public string FeaturesString { get; set; }

        /// <summary>
        /// 重写ToString
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return string.Format("{0}|{1}|{2}|{3}|{4}", Doors, Seats, Suitcases, IsAutomatic, HasAirConditioning);
        }

        /// <summary>
        /// 获取行李箱的中文说明（如：2大2小）
        /// </summary>
        /// <returns></returns>
        public virtual string GetCNSuitcases()
        {
            var str = string.IsNullOrWhiteSpace(Suitcases) ? "" : Suitcases.ToLower();
            if (str == "Holds 2 small Suitcases".ToLower())
            {
                return "2小";
            }
            else if (str == "Holds 3 small Suitcases".ToLower())
            {
                return "3小";
            }
            else if (str == "Holds 2 medium suitcases".ToLower())
            {
                return "2小";
            }
            else if (str == "Holds 2 medium, 2 small Suitcases".ToLower())
            {
                return "4小";
            }
            else if (str == "Holds 4 medium suitcases".ToLower())
            {
                return "4小";
            }
            else if (str == "Holds 1 medium, 2 small Suitcases".ToLower())
            {
                return "3小";
            }
            else if (str == "Holds 1 large, 1 small Suitcases".ToLower())
            {
                return "1大1小";
            }
            else if (str == "Holds 1 large, 2 small Suitcases".ToLower())
            {
                return "1大2小";
            }
            else if (str == "Holds 1 large, 3 small Suitcases".ToLower())
            {
                return "1大3小";
            }
            else if (str == "Holds 2 large, 1 small Suitcases".ToLower())
            {
                return "2大1小";
            }
            else if (str == "Holds 2 large, 2 small Suitcases".ToLower())
            {
                return "2大2小";
            }
            else if (str == "Holds 2 large, 3 small Suitcases".ToLower())
            {
                return "2大3小";
            }
            else if (str == "Holds 3 Large &amp; 1 small Suitcases".ToLower() || str == "Holds 3 Large & 1 small Suitcases".ToLower())
            {
                return "3大1小";
            }
            else if (str == "Holds 3 large, 2 small Suitcases".ToLower())
            {
                return "3大2小";
            }
            else if (str == "Holds 4-5 medium suitcases".ToLower())
            {
                return "5小";
            }
            else if (str == "Holds 5 large Suitcases".ToLower())
            {
                return "5大";
            }
            else if (str == "Holds 5+ large Suitcases".ToLower())
            {
                return "5大";
            }
            else if (str == "Holds 1 Small Suitcases".ToLower())
            {
                return "1小";
            }
            else if (str == "Holds 1 large Suitcases".ToLower())
            {
                return "1大";
            }
            else if (str == "Holds 1 large, 2 overnight Suitcases".ToLower())
            {
                return "1大2小";
            }
            else if (str == "Holds 2 medium, 2 overnight Suitcases".ToLower())
            {
                return "2中2小";
            }
            else if (str == "Holds 3 medium suitcases".ToLower())
            {
                return "3中";
            }
            else if (str == "Holds 3 medium, 2 small Suitcases".ToLower())
            {
                return "3中2小";
            }
            else if (str == "Holds 3 large, 3 small suitcases".ToLower())
            {
                return "3大3小";
            }
            else if (str == "Holds 4 large Suitcases".ToLower())
            {
                return "4大";
            }
            else if (str == "Holds 4 large, 3 small Suitcases".ToLower())
            {
                return "4大3小";
            }
            else if (str == "Holds 5 large, 5 small Suitcases".ToLower())
            {
                return "5大5小";
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(str))
                {
                    LogHelper.Logger.WarnFormat("解析行李箱出错：{0}。", str);
                }

                return "0件";
            }
        }
    }
}
